
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>书名 · 书名</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="作者">
        <meta name="identifier" content="图书编号" scheme="ISBN">
        
    
    <link rel="stylesheet" href="gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-code/plugin.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-back-to-top-button/plugin.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-intopic-toc/style.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-flexible-alerts/style.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">

    
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter active" data-level="1.1" data-path="./">
            
                <a href="./">
            
                    
                    书名
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Books</li>
        
        
    
        <li class="chapter " data-level="2.1" >
            
                <span>
            
                    
                    Java
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1.1" data-path="books/java/001环境变量.html">
            
                <a href="books/java/001环境变量.html">
            
                    
                    001环境变量
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2" data-path="books/java/002Java初体验.html">
            
                <a href="books/java/002Java初体验.html">
            
                    
                    002Java初体验
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3" data-path="books/java/003变量命名及数据类型.html">
            
                <a href="books/java/003变量命名及数据类型.html">
            
                    
                    003变量命名及数据类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.4" data-path="books/java/004运算符.html">
            
                <a href="books/java/004运算符.html">
            
                    
                    004运算符
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.5" data-path="books/java/005选择结构.html">
            
                <a href="books/java/005选择结构.html">
            
                    
                    005选择结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.6" data-path="books/java/006循环结构.html">
            
                <a href="books/java/006循环结构.html">
            
                    
                    006循环结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.7" data-path="books/java/007数组.html">
            
                <a href="books/java/007数组.html">
            
                    
                    007数组
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.8" data-path="books/java/008类和对象方法.html">
            
                <a href="books/java/008类和对象方法.html">
            
                    
                    008类和对象方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.9" data-path="books/java/009构造方法.html">
            
                <a href="books/java/009构造方法.html">
            
                    
                    009构造方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.10" data-path="books/java/010封装与关键字static.html">
            
                <a href="books/java/010封装与关键字static.html">
            
                    
                    010封装与关键字Static
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.11" data-path="books/java/011 继承.html">
            
                <a href="books/java/011 继承.html">
            
                    
                    011 继承
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.12" data-path="books/java/012方法重写.html">
            
                <a href="books/java/012方法重写.html">
            
                    
                    012方法重写
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.13" data-path="books/java/013多态.html">
            
                <a href="books/java/013多态.html">
            
                    
                    013多态
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.14" data-path="books/java/014抽象类抽象方法.html">
            
                <a href="books/java/014抽象类抽象方法.html">
            
                    
                    014抽象类抽象方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.15" data-path="books/java/015接口.html">
            
                <a href="books/java/015接口.html">
            
                    
                    015接口
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.16" data-path="books/java/016异常.html">
            
                <a href="books/java/016异常.html">
            
                    
                    016异常
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.17" data-path="books/java/017集合.html">
            
                <a href="books/java/017集合.html">
            
                    
                    017集合
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.18" data-path="books/java/017集合2.html">
            
                <a href="books/java/017集合2.html">
            
                    
                    017集合2
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.19" data-path="books/java/018泛型.html">
            
                <a href="books/java/018泛型.html">
            
                    
                    018泛型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.20" data-path="books/java/019Collections算法类.html">
            
                <a href="books/java/019Collections算法类.html">
            
                    
                    019Collections算法类
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.21" data-path="books/java/020枚举.html">
            
                <a href="books/java/020枚举.html">
            
                    
                    020枚举
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.22" data-path="books/java/021包装类.html">
            
                <a href="books/java/021包装类.html">
            
                    
                    021包装类
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.23" data-path="books/java/022常用类.html">
            
                <a href="books/java/022常用类.html">
            
                    
                    022常用类
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.24" data-path="books/java/023File类.html">
            
                <a href="books/java/023File类.html">
            
                    
                    023File类
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.25" data-path="books/java/024IO流.html">
            
                <a href="books/java/024IO流.html">
            
                    
                    024IO流
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.26" data-path="books/java/025多线程.html">
            
                <a href="books/java/025多线程.html">
            
                    
                    025多线程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.27" data-path="books/java/025多线程线程池.html">
            
                <a href="books/java/025多线程线程池.html">
            
                    
                    025多线程线程池
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.28" data-path="books/java/026网络编程Socket.html">
            
                <a href="books/java/026网络编程Socket.html">
            
                    
                    026网络编程Socket
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.29" data-path="books/java/027XML解析.html">
            
                <a href="books/java/027XML解析.html">
            
                    
                    027XML解析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.30" data-path="books/java/028 注解.html">
            
                <a href="books/java/028 注解.html">
            
                    
                    028 注解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.31" data-path="books/java/029 Lambda表达式.html">
            
                <a href="books/java/029 Lambda表达式.html">
            
                    
                    029 Lambda表达式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.32" data-path="books/java/029 反射.html">
            
                <a href="books/java/029 反射.html">
            
                    
                    029 反射
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.2" >
            
                <span>
            
                    
                    Mybatis
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.2.1" data-path="books/mybatis/MyBatis.html">
            
                <a href="books/mybatis/MyBatis.html">
            
                    
                    MyBatis
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.2.1.1" >
            
                <span>
            
                    
                    MyBatis
            
                </span>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.3" >
            
                <span>
            
                    
                    Mysql
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.3.1" data-path="books/mysql/01 SQL通用语法.html">
            
                <a href="books/mysql/01 SQL通用语法.html">
            
                    
                    01 SQL通用语法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.2" data-path="books/mysql/02 DDL.html">
            
                <a href="books/mysql/02 DDL.html">
            
                    
                    02 DDL
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.3" data-path="books/mysql/03 DML.html">
            
                <a href="books/mysql/03 DML.html">
            
                    
                    03 DML
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.4" data-path="books/mysql/04 DQL.html">
            
                <a href="books/mysql/04 DQL.html">
            
                    
                    04 DQL
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.5" data-path="books/mysql/05 DCL.html">
            
                <a href="books/mysql/05 DCL.html">
            
                    
                    05 DCL
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.6" data-path="books/mysql/06 函数.html">
            
                <a href="books/mysql/06 函数.html">
            
                    
                    06 函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.7" data-path="books/mysql/07 约束.html">
            
                <a href="books/mysql/07 约束.html">
            
                    
                    07 约束
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.8" data-path="books/mysql/08 多表查询.html">
            
                <a href="books/mysql/08 多表查询.html">
            
                    
                    08 多表查询
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.9" data-path="books/mysql/09 事务.html">
            
                <a href="books/mysql/09 事务.html">
            
                    
                    09 事务
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.10" data-path="books/mysql/999zzz.html">
            
                <a href="books/mysql/999zzz.html">
            
                    
                    999zzz
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.11" data-path="books/mysql/MySql.html">
            
                <a href="books/mysql/MySql.html">
            
                    
                    MySql
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.12" data-path="books/mysql/sql.html">
            
                <a href="books/mysql/sql.html">
            
                    
                    Sql
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.4" >
            
                <span>
            
                    
                    Spring
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.4.1" data-path="books/spring/spring.html">
            
                <a href="books/spring/spring.html">
            
                    
                    Spring
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.5" >
            
                <span>
            
                    
                    SpringMVC
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.5.1" data-path="books/springMVC/springMVC.html">
            
                <a href="books/springMVC/springMVC.html">
            
                    
                    SpringMVC
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.6" >
            
                <span>
            
                    
                    整合
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.6.1" data-path="books/整合/Mybatis框架.html">
            
                <a href="books/整合/Mybatis框架.html">
            
                    
                    Mybatis框架
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.6.2" data-path="books/整合/SpringBoot.html">
            
                <a href="books/整合/SpringBoot.html">
            
                    
                    SpringBoot
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.6.3" data-path="books/整合/springmvc框架.html">
            
                <a href="books/整合/springmvc框架.html">
            
                    
                    Springmvc框架
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.6.4" data-path="books/整合/spring框架.html">
            
                <a href="books/整合/spring框架.html">
            
                    
                    Spring框架
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >书名</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="spring-&#x57FA;&#x672C;&#x4F7F;&#x7528;">Spring &#x57FA;&#x672C;&#x4F7F;&#x7528;</h1>
<h1 id="spring-&#x4E2D;-bean-&#x590D;&#x6742;&#x7C7B;&#x578B;-&#x8D4B;&#x521D;&#x59CB;&#x503C;">spring &#x4E2D; Bean &#x590D;&#x6742;&#x7C7B;&#x578B; &#x8D4B;&#x521D;&#x59CB;&#x503C;</h1>
<blockquote>
<p><strong>array, list, set, map, &#x65E5;&#x671F;</strong></p>
</blockquote>
<h1 id="spring-&#x6846;&#x67B6;&#x4E2D;aop">Spring &#x6846;&#x67B6;&#x4E2D;AOP</h1>
<p><strong>&#x4EE3;&#x7406;&#x6A21;&#x5F0F;&#x8BB2;&#x89E3;</strong></p>
<p><strong>&#x4F5C;&#x7528;: &#x5728;&#x4E0D;&#x4FEE;&#x6539;&#x539F;&#x59CB;&#x4EE3;&#x7801;&#x7684;&#x60C5;&#x51B5;&#x4E0B;,&#x901A;&#x8FC7;&#x4EE3;&#x7406;&#x7C7B;,&#x5BF9;&#x539F;&#x59CB;&#x7C7B;&#x589E;&#x52A0;&#x989D;&#x5916;&#x7684;&#x529F;&#x80FD; </strong></p>
<h2 id="11-&#x9759;&#x6001;&#x4EE3;&#x7406;">1.1 &#x9759;&#x6001;&#x4EE3;&#x7406;</h2>
<blockquote>
<p><strong>&#x57FA;&#x4E8E;&#x63A5;&#x53E3;&#x7684;&#x4EE3;&#x7406;</strong></p>
</blockquote>
<p><strong>&#x5F00;&#x53D1;&#x4EE3;&#x7406;&#x5BF9;&#x8C61;&#x7684;&#x539F;&#x5219;:</strong></p>
<ol>
<li><strong>&#x4EE3;&#x7406;&#x5BF9;&#x8C61;&#x9700;&#x8981;&#x5B9E;&#x73B0;&#x88AB;&#x4EE3;&#x7406;&#x5BF9;&#x8C61;&#x4E00;&#x6837;&#x7684;&#x63A5;&#x53E3; --&gt; &#x9762;&#x5411;&#x63A5;&#x53E3;&#x5F00;&#x53D1;</strong></li>
<li><strong>&#x4EE3;&#x7406;&#x5BF9;&#x8C61;&#x8981;&#x4F9D;&#x8D56;&#x88AB;&#x4EE3;&#x7406;&#x5BF9;&#x8C61;                        --&gt; &#x4FDD;&#x6301;&#x539F;&#x6709;&#x529F;&#x80FD;&#x4E0D;&#x53D8;</strong></li>
</ol>
<p><strong>&#x4F18;&#x70B9;: &#x7B80;&#x5355;, &#x89E3;&#x51B3;&#x4E86;&#x4E0D;&#x4FEE;&#x6539;&#x6E90;&#x7801;&#x5C31;&#x80FD;&#x5B9E;&#x73B0;&#x529F;&#x80FD;&#x589E;&#x5F3A;</strong></p>
<p><strong>&#x7F3A;&#x70B9;: &#x4EE3;&#x7801;&#x4E0D;&#x5B9C;&#x7EF4;&#x62A4;, &#x56E0;&#x4E3A;&#x4EE3;&#x7406;&#x5BF9;&#x8C61;&#x9700;&#x8981;&#x5B9E;&#x73B0;&#x88AB;&#x4EE3;&#x7406;&#x5BF9;&#x8C61;&#x540C;&#x6837;&#x7684;&#x63A5;&#x53E3;,&#x63A5;&#x53E3;&#x589E;&#x52A0;&#x65F6;,&#x53CC;&#x65B9;&#x90FD;&#x9700;&#x8981;&#x7EF4;&#x62A4;</strong></p>
<pre><code> public class UserMapperImplStaticProxy implements UserMapper {

     private UserMapperImpl userMapperImpl = new UserMapperImpl();

     @Override
     public Integer delete(Integer id) {
         System.out.println(&quot;-----------log&#x65E5;&#x5FD7;-------------&quot;);
         Integer delete = userMapperImpl.delete(id);
         System.out.println(&quot;-----------log&#x65E5;&#x5FD7;-------------&quot;);
         return delete;
     }

     @Override
     public Integer add() {
         System.out.println(&quot;-----------log&#x65E5;&#x5FD7;-------------&quot;);
         Integer add = userMapperImpl.add();
         System.out.println(&quot;-----------log&#x65E5;&#x5FD7;-------------&quot;);
         return add;
     }

     @Override
     public Integer update() {
         return null;
     }
 }
</code></pre><h2 id="12-jdk&#x7684;&#x52A8;&#x6001;&#x4EE3;&#x7406;">1.2 jdk&#x7684;&#x52A8;&#x6001;&#x4EE3;&#x7406;</h2>
<blockquote>
<p><strong>&#x7A0B;&#x5E8F;&#x8FD0;&#x884C;&#x8FC7;&#x7A0B;&#x4E2D;, &#x901A;&#x8FC7;jdk&#x63D0;&#x4F9B;&#x7684;&#x4EE3;&#x7406;&#x6280;&#x672F;, &#x52A8;&#x6001;&#x7684;&#x4E3A;&#x67D0;&#x4E2A;&#x7C7B;&#x4EA7;&#x751F;&#x52A8;&#x6001;&#x4EE3;&#x7406;&#x5BF9;&#x8C61;&#x7684;&#x8FC7;&#x7A0B;</strong></p>
</blockquote>
<p><strong>&#x5F00;&#x53D1;&#x4EE3;&#x7406;&#x5BF9;&#x8C61;&#x7684;&#x539F;&#x5219;:</strong></p>
<ol>
<li><strong>&#x4EE3;&#x7406;&#x5BF9;&#x8C61;&#x4E0D;&#x9700;&#x8981;&#x5B9E;&#x73B0;&#x63A5;&#x53E3;, &#x4F46;&#x662F;&#x88AB;&#x4EE3;&#x7406;&#x5BF9;&#x8C61;( &#x76EE;&#x6807;&#x5BF9;&#x8C61; )&#x8981;&#x5B9E;&#x73B0;&#x63A5;&#x53E3;, &#x5426;&#x5219;&#x4E0D;&#x80FD;&#x4F7F;&#x7528;JDK&#x52A8;&#x6001;&#x4EE3;&#x7406;</strong></li>
<li><strong>&#x4EE3;&#x7406;&#x5BF9;&#x8C61;&#x7684;&#x751F;&#x6210;, &#x662F;&#x4F7F;&#x7528; JDK &#x539F;&#x751F;&#x7684; API ,&#x52A8;&#x6001;&#x7684;&#x5728;&#x5185;&#x5B58;&#x6784;&#x5EFA;&#x4EE3;&#x7406;&#x5BF9;&#x8C61;</strong></li>
<li><strong>&#x52A8;&#x6001;&#x4EE3;&#x7406;&#x4E5F;&#x53EB;&#x505A;: JDK &#x4EE3;&#x7406;, &#x63A5;&#x53E3;&#x4EE3;&#x7406;</strong></li>
</ol>
<pre><code> public class JDKDynamicProxy {

     public static void main(String[] args) {

         final UserMapperImpl userMapperImpl = new UserMapperImpl();

         //&#x901A;&#x8FC7;JDK&#x7684;&#x52A8;&#x6001;&#x4EE3;&#x7406;&#x65B9;&#x5F0F; &#x83B7;&#x53D6; UserMapperImpl&#x7684;&#x4EE3;&#x7406;&#x5BF9;&#x8C61;
         /*
         * &#x53C2;&#x6570;1&#xFF1A;  ClassLoader loader  &#x7C7B;&#x52A0;&#x8F7D;&#x5668;
         *       &#x7C7B;&#x52A0;&#x8F7D;&#x5668;&#x7684;&#x4F5C;&#x7528;&#xFF1A; &#x4EE3;&#x7406;&#x7C7B;&#x662F;&#x4E0D;&#x4F1A;&#x88AB;&#x5206;&#x914D;&#x7C7B;&#x52A0;&#x8F7D;&#x5668;
         *       &#x501F;&#x7528;&#x5176;&#x5B83;&#x7C7B;&#x7684;&#x52A0;&#x8F7D;&#x5668; &#x5B9E;&#x73B0;&#x7C7B;&#x7684;&#x52A0;&#x8F7D;&#x548C;&#x5BF9;&#x8C61;&#x7684;&#x521B;&#x5EFA;
         * &#x53C2;&#x6570;2:   Class&lt;?&gt;[] interfaces
         *         &#x88AB;&#x4EE3;&#x7406;&#x7C7B;&#x5B9E;&#x73B0;&#x7684;&#x63A5;&#x53E3;    Class
         * &#x53C2;&#x6570;3:   InvocationHandler
         *         &#x8981;&#x5B9E;&#x73B0;&#x529F;&#x80FD;&#x589E;&#x5F3A;&#x7684;&#x5BF9;&#x8C61;
         * */

         Class clazz = UserMapperImpl.class;
         Class[] interfaces = clazz.getInterfaces();

         // &#x901A;&#x8FC7;&#x533F;&#x540D;&#x5185;&#x90E8;&#x7C7B; &#x521B;&#x5EFA;&#x4E86;InvocationHandler&#x7C7B;&#x578B;&#x7684;&#x5B9E;&#x4F8B;&#x5BF9;&#x8C61;
         InvocationHandler  invocationHandler = new InvocationHandler() {
             //&#x7F16;&#x5199;&#x529F;&#x80FD;&#x589E;&#x5F3A;&#x65B9;&#x6CD5;
             /*
             *Object proxy  &#x751F;&#x6210;&#x7684;&#x4EE3;&#x7406;&#x5BF9;&#x8C61;
             *Method method  &#x65B9;&#x6CD5;&#x5BF9;&#x8C61;    &#x901A;&#x8FC7;&#x4EE3;&#x7406;&#x5BF9;&#x8C61;&#x8C03;&#x7528;&#x65B9;&#x6CD5;&#x65F6;&#x90A3;&#x4E48;&#x4F1A;&#x5C06;&#x4EE3;&#x7406;&#x5BF9;&#x8C61;&#x8C03;&#x7528;&#x7684;&#x65B9;&#x5F0F; &#x5C01;&#x88C5;&#x6210;&#x5BF9;&#x8C61;&#x4F20;&#x5165;&#x5F53;&#x524D;&#x65B9;&#x6CD5;
             *Object[] args  &#x4EE3;&#x7406;&#x5BF9;&#x8C61;&#x8C03;&#x7528;&#x65B9;&#x6CD5;&#x7684;&#x53C2;&#x6570; &#x4E5F;&#x4F1A;&#x4EE5;&#x6570;&#x7EC4;&#x7684;&#x5F62;&#x5F0F;&#x4F20;&#x5165;&#x5F53;&#x524D;&#x65B9;&#x6CD5;
             *
             * return Object   &#x6267;&#x884C;method&#x65B9;&#x6CD5;&#x7684;&#x8FD4;&#x56DE;&#x503C;
             * */
             @Override
             public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

                 String name = method.getName();
                 System.out.println(&quot;method name = &quot;+name);

                 System.out.println(&quot;args = &quot; + args[0]);

                 System.out.println(&quot;----------log&#x65E5;&#x5FD7;-----------&quot;);
                 Object invoke = method.invoke(userMapperImpl, args);

                 return invoke;
             }
         };
         // o &#x901A;&#x8FC7;&#x52A8;&#x6001;&#x4EE3;&#x7406;&#x65B9;&#x5F0F;&#x83B7;&#x53D6;&#x7684;&#x52A8;&#x6001;&#x4EE3;&#x7406;&#x5BF9;&#x8C61;
         /**
          *&#x53C2;&#x6570;1&#xFF1A;&#x7C7B;&#x52A0;&#x8F7D;&#x5668;&#xFF0C;&#x52A8;&#x6001;&#x4EE3;&#x7406;&#x5BF9;&#x8C61;&#x6CA1;&#x6709;&#x7C7B;&#x52A0;&#x8F7D;&#x5668; &#x9700;&#x8981;&#x501F;&#x52A9;&#x522B;&#x7684;&#x7C7B;&#x7684;&#x52A0;&#x8F7D;&#x5668;&#x5B9E;&#x73B0;&#x7C7B;&#x7684;&#x52A0;&#x8F7D;
          * &#x7C7B;&#x52A0;&#x8F7D;&#x5668;&#x7684;&#x4F5C;&#x7528;&#xFF1A;
          *  1.&#x52A0;&#x8F7D;class&#x6587;&#x4EF6;&#x5230;JVM&#x865A;&#x62DF;&#x673A;
          *  2.&#x521B;&#x5EFA;&#x7C7B;&#x7684;class&#x5BF9;&#x8C61;&#xFF0C;&#x8FDB;&#x800C;&#x521B;&#x5EFA;&#x7C7B;&#x7684;&#x5B9E;&#x4F8B;&#x5316;&#x5BF9;&#x8C61;
          *
          * &#x53C2;&#x6570;2:&#x539F;&#x59CB;&#x7C7B;&#x5B9E;&#x73B0;&#x7684;&#x6240;&#x6709;&#x63A5;&#x53E3;  &#x57FA;&#x4E8E;jdk&#x7684;&#x52A8;&#x6001;&#x4EE3;&#x7406;&#x8981;&#x6C42;&#x4EE3;&#x7406;&#x5BF9;&#x8C61;&#x548C;&#x539F;&#x59CB;&#x5BF9;&#x8C61;&#x8981;&#x5B9E;&#x73B0;&#x76F8;&#x540C;&#x7684;&#x63A5;&#x53E3;
          *
          * &#x53C2;&#x6570;3&#xFF1A;&#x4EE3;&#x7406;&#x5BF9;&#x8C61;&#x989D;&#x5916;&#x589E;&#x52A0;&#x7684;&#x529F;&#x80FD;  InvocationHandler
          *
          */
         UserMapper  o = (UserMapper) Proxy.newProxyInstance(JDKDynamicProxy.class.getClassLoader(), interfaces, invocationHandler);
         Integer delete = o.delete(1);
         System.out.println(&quot;delete = &quot; + delete);

     }
 }
</code></pre><h2 id="13-cglib&#x4EE3;&#x7406;">1.3 cglib&#x4EE3;&#x7406;</h2>
<p><strong>&#x5F00;&#x53D1;&#x4EE3;&#x7406;&#x5BF9;&#x8C61;&#x7684;&#x539F;&#x5219;&#xFF1A;</strong></p>
<ol>
<li><strong>&#x4EE3;&#x7406;&#x5BF9;&#x8C61;&#x65E0;&#x9700;&#x548C;&#x76EE;&#x6807;&#x5BF9;&#x8C61;&#x5B9E;&#x73B0;&#x540C;&#x6837;&#x7684;&#x63A5;&#x53E3;</strong></li>
<li><strong>&#x4EE3;&#x7406;&#x5BF9;&#x8C61;&#x9700;&#x8981;&#x548C;&#x76EE;&#x6807;&#x5BF9;&#x8C61;&#x5B58;&#x5728;&#x7236;&#x5B50;&#x7C7B;&#x5173;&#x7CFB;</strong></li>
</ol>
<pre><code> public class CglibProxy {

     public static void main(String[] args) {

         UserMapperImpl userMapper = new UserMapperImpl();

         Enhancer enhancer = new Enhancer();

         //&#x8BBE;&#x7F6E;&#x751F;&#x6210;&#x7684;&#x4EE3;&#x7406;&#x7C7B;&#x7684;&#x7236;&#x7C7B;
         enhancer.setSuperclass(UserMapperImpl.class);
         //&#x8BBE;&#x7F6E;&#x4EE3;&#x7406;&#x7C7B;&#x7684;&#x589E;&#x5F3A;&#x7684;&#x529F;&#x80FD;
         MethodInterceptor methodInterceptor = new MethodInterceptor() {

             // Method method      Object[] objects
             @Override
             public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {

                 System.out.println(&quot;---------log&#x65E5;&#x5FD7;------------&quot;);

                 Object invoke = method.invoke(userMapper, objects);

                 System.out.println(&quot;---------log&#x65E5;&#x5FD7;------------&quot;);
                 return invoke;
             }
         };
         enhancer.setCallback(methodInterceptor);
         // &#x521B;&#x5EFA;&#x4EE3;&#x7406;&#x5BF9;&#x8C61;   &#x4EE3;&#x7406;&#x5BF9;&#x8C61;&#x662F; UserMapperImpl&#x7684;&#x5B50;&#x7C7B;
         UserMapperImpl o = (UserMapperImpl) enhancer.create();
         Integer delete = o.delete(1);
         System.out.println(&quot;delete = &quot; + delete);


     }
 }
</code></pre><h1 id="aop-&#x672F;&#x8BED;">AOP &#x672F;&#x8BED;</h1>
<ul>
<li><strong>&#x6A2A;&#x5207;&#x5173;&#x6CE8;&#x70B9;:&#x8DE8;&#x8D8A;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x591A;&#x4E2A;&#x6A21;&#x5757;&#x7684;&#x65B9;&#x6CD5;&#x6216;&#x529F;&#x80FD;&#x3002;&#x5373;&#x662F;&#xFF0C;&#x4E0E;&#x6211;&#x4EEC;&#x4E1A;&#x52A1;&#x903B;&#x8F91;&#x65E0;&#x5173;&#x7684;&#xFF0C;&#x4F46;&#x662F;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x5173;&#x6CE8;&#x7684;&#x90E8;&#x5206;&#xFF0C;&#x5C31;&#x662F;&#x6A2A;&#x5207;&#x5173;&#x6CE8;&#x70B9;&#x3002;&#x5982;&#x65E5;&#x5FD7;,&#x5B89;&#x5168;,&#x7F13;&#x5B58;,&#x4E8B;&#x52A1;&#x7B49;&#x7B49;....</strong></li>
<li><strong>&#x5207;&#x9762;( ASPECT ): &#x6A2A;&#x5207;&#x5173;&#x6CE8;&#x70B9;&#x6A21;&#x5757;&#x5316;&#x7684;&#x7279;&#x6B8A;&#x5BF9;&#x8C61;, &#x5373;,&#x662F;&#x4E00;&#x4E2A;&#x7C7B;</strong></li>
<li><strong>&#x901A;&#x77E5;( Advice ): &#x5207;&#x9762;&#x9700;&#x8981;&#x5B8C;&#x6210;&#x7684;&#x4EFB;&#x52A1;, &#x5373;,&#x7C7B;&#x4E2D;&#x7684;&#x65B9;&#x6CD5;</strong>
<strong>&#x524D;&#x7F6E;&#x901A;&#x77E5;, &#x540E;&#x7F6E;&#x901A;&#x77E5;, &#x73AF;&#x7ED5;&#x901A;&#x77E5;, &#x5F02;&#x5E38;&#x901A;&#x77E5;, &#x6700;&#x7EC8;&#x901A;&#x77E5;</strong></li>
<li><strong>&#x76EE;&#x6807;( Target ): &#x88AB;&#x901A;&#x77E5;&#x5BF9;&#x8C61;</strong></li>
<li><strong>&#x4EE3;&#x7406;( Proxy ): &#x5411;&#x76EE;&#x6807;&#x5BF9;&#x8C61;&#x901A;&#x77E5;&#x540E;&#x521B;&#x5EFA;&#x7684;&#x5BF9;&#x8C61;</strong></li>
<li><strong>&#x5207;&#x5165;&#x70B9;( PointCut ): &#x5207;&#x9762;&#x901A;&#x77E5;&#x6267;&#x884C;&#x7684;&quot;&#x5730;&#x70B9;&quot;&#x7684;&#x5B9A;&#x4E49;</strong></li>
<li><strong>&#x8FDE;&#x63A5;&#x70B9;( JoinCut ):  &#x4E0E;&#x5207;&#x5165;&#x70B9;&#x5339;&#x914D;&#x6267;&#x884C;&#x70B9;</strong></li>
</ul>
<h2 id="1-&#x57FA;&#x4E8E;&#x63A5;&#x53E3;&#x5F62;&#x5F0F;&#x5B9E;&#x73B0;">1. &#x57FA;&#x4E8E;&#x63A5;&#x53E3;&#x5F62;&#x5F0F;&#x5B9E;&#x73B0;</h2>
<blockquote>
<p><strong>&#x4F7F;&#x7528; Spring-aop &#x63A5;&#x53E3;&#x65B9;&#x5F0F;&#x5B9E;&#x73B0; aop , &#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x81EA;&#x5B9A;&#x4E49;&#x901A;&#x77E5;&#x6765;&#x4F9B;Spring-aop&#x8BC6;&#x522B;</strong></p>
</blockquote>
<p><strong>&#x5207;&#x5165;&#x70B9;&#x8868;&#x8FBE;&#x5F0F;</strong></p>
<p><strong>&#x4F5C;&#x7528;: &#x58F0;&#x660E;&#x5BF9;&#x54EA;&#x4E2A;&#x7C7B;&#x4E2D;&#x7684;&#x54EA;&#x4E2A;&#x65B9;&#x6CD5;&#x8FDB;&#x884C;&#x589E;&#x5F3A;</strong></p>
<p><strong>&#x8BED;&#x6CD5;:</strong></p>
<p><strong>execution([ &#x8BBF;&#x95EE;&#x5168;&#x9650;&#x4FEE;&#x9970;&#x7B26; ] &#x8FD4;&#x56DE;&#x503C;&#x7C7B;&#x578B; [ &#x5168;&#x9650;&#x5B9A;&#x7C7B;&#x540D; ] &#x65B9;&#x6CD5;&#x540D;( &#x53C2;&#x6570;&#x5217;&#x8868; ) [ &#x5F02;&#x5E38; ])</strong></p>
<ul>
<li><strong>&#x8BBF;&#x95EE;&#x5168;&#x9650;&#x4FEE;&#x9970;&#x7B26;:</strong><ul>
<li><strong>&#x53EF;&#x9009;&#x9879;, &#x4E0D;&#x5199;&#x5C31;&#x662F;&#x5305;&#x542B;&#x6240;&#x6709;&#x4FEE;&#x9970;&#x7B26;</strong></li>
<li><strong>&#x5199;public &#x5C31;&#x8868;&#x793A;&#x53EA;&#x5305;&#x62EC; &#x516C;&#x5F00;&#x7684;&#x65B9;&#x6CD5;</strong></li>
</ul>
</li>
<li><strong>&#x8FD4;&#x56DE;&#x503C;&#x7C7B;&#x578B;</strong><ul>
<li><strong>&#x5FC5;&#x586B;&#x9879;, * &#x8868;&#x793A;&#x4EFB;&#x610F;&#x7C7B;&#x578B;&#x7684;&#x8FD4;&#x56DE;&#x503C;</strong></li>
</ul>
</li>
<li><strong>&#x5168;&#x9650;&#x5B9A;&#x7C7B;&#x540D;</strong><ul>
<li><strong>&#x53EF;&#x9009;&#x9879;,  &#x4E24;&#x4E2A;&#x70B9; .. &#x8868;&#x793A;&#x53CD;&#x5168;&#x5305;&#x4EE5;&#x53CA;&#x5B50;&#x5305;&#x4E0B;&#x7684;&#x6240;&#x6709;&#x7C7B;, &#x7701;&#x7565;&#x8868;&#x793A;&#x6240;&#x6709;&#x7C7B;</strong></li>
</ul>
</li>
<li><strong>&#x65B9;&#x6CD5;&#x540D;</strong><ul>
<li><strong>&#x5FC5;&#x586B;&#x9879;, <em> &#x8868;&#x793A;&#x6240;&#x6709;&#x65B9;&#x6CD5;, set</em> &#x8868;&#x793A;&#x6240;&#x6709;set&#x65B9;&#x6CD5;</strong></li>
</ul>
</li>
<li><strong>&#x53C2;&#x6570;&#x5217;&#x8868;</strong><ul>
<li><strong>&#x5FC5;&#x586B;&#x9879;</strong></li>
<li><strong>() &#x8868;&#x793A;&#x6CA1;&#x6709;&#x53C2;&#x6570;&#x7684;&#x65B9;&#x6CD5;</strong></li>
<li><strong>(..)  &#x8868;&#x793A;&#x4EFB;&#x610F;&#x53C2;&#x6570;&#x7C7B;&#x578B;&#x6570;&#x91CF;&#x7684;&#x65B9;&#x6CD5;</strong></li>
<li><strong>(*) &#x8868;&#x793A;&#x53EA;&#x6709;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#x7684;&#x65B9;&#x6CD5;</strong></li>
<li><strong>(*, String) &#x8868;&#x793A;&#x7B2C;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#x7C7B;&#x578B;&#x4EFB;&#x610F;, &#x7B2C;&#x4E8C;&#x4E2A;&#x53C2;&#x6570;&#x7C7B;&#x578B;&#x4E3A; String</strong></li>
</ul>
</li>
<li><strong>&#x5F02;&#x5E38;&#x4FE1;&#x606F;</strong><ul>
<li><strong>&#x53EF;&#x9009;&#x9879;, &#x7701;&#x7565;&#x662F;&#x8868;&#x793A;&#x4EFB;&#x4F55;&#x5F02;&#x5E38;&#x4FE1;&#x606F;</strong></li>
</ul>
</li>
</ul>
<p><strong>&#x5BF9;&#x5E94;&#x7684;&#x63A5;&#x53E3;&#x662F;:</strong></p>
<ol>
<li><strong>&#x524D;&#x7F6E;&#x901A;&#x77E5;: MethodBeforeAdvice</strong></li>
<li><strong>&#x8FD4;&#x56DE;&#x901A;&#x77E5;: AfterReturningAdvice</strong></li>
<li><strong>&#x5F02;&#x5E38;&#x901A;&#x77E5;: ThrowsAdvice</strong></li>
<li><strong>&#x73AF;&#x7ED5;&#x901A;&#x77E5;: MethodIntercepter</strong></li>
</ol>
<pre><code>    public class MyBeforeAdvice implements MethodBeforeAdvice {
        @Override
        public void before(Method method, Object[] args, Object target) throws Throwable {
            System.out.println(&quot;========log=======&quot;);
            String name = method.getName();
            System.out.println(&quot;name = &quot; + name);
            System.out.println(&quot;method.args = &quot; + Arrays.toString(args));
        }
    }



    &lt;!--1.&#x6258;&#x7BA1;&#x901A;&#x77E5;&#x548C;&#x88AB;&#x4EE3;&#x7406;&#x7684;&#x7C7B;--&gt;
        &lt;bean id=&quot;myBeforeAdvice&quot; class=&quot;cn.kgc.spring08.advice.MyBeforeAdvice&quot;&gt;&lt;/bean&gt;
        &lt;bean id=&quot;calculator&quot; class=&quot;cn.kgc.spring08.entity.Calculator&quot;&gt;&lt;/bean&gt;

        &lt;!--&#x914D;&#x7F6E;aop&#x76F8;&#x5173;&#x53C2;&#x6570;--&gt;
        &lt;aop:config&gt;
            &lt;!--&#x5B9A;&#x4E49;&#x5207;&#x70B9;
                &#x5207;&#x70B9;&#x8868;&#x8FBE;&#x5F0F;&#xFF1A;  &#x4F7F;&#x7528;&#x4E00;&#x4E2A;&#x8868;&#x8FBE;&#x5F0F;&#x9009;&#x62E9;&#x90A3;&#x4E9B;&#x65B9;&#x6CD5;&#x9700;&#x8981;&#x88AB;&#x589E;&#x5F3A;
                execution([&#x8BBF;&#x95EE;&#x6743;&#x9650;&#x4FEE;&#x9970;&#x7B26;] &#x8FD4;&#x56DE;&#x503C; [&#x5168;&#x9650;&#x5B9A;&#x540D;]&#x65B9;&#x6CD5;&#x540D;(&#x53C2;&#x6570;&#x5217;&#x8868;)[&#x5F02;&#x5E38;])
            --&gt;
            &lt;aop:pointcut id=&quot;p1&quot; expression=&quot;execution(public * *(..))&quot;/&gt;
            &lt;!--&#x914D;&#x7F6E;&#x901A;&#x77E5;
            advice-ref :&#x5173;&#x8054;&#x901A;&#x77E5;&#x5BF9;&#x8C61;
            pointcut-ref&#xFF1A; &#x5173;&#x8054;&#x5207;&#x70B9;&#x5BF9;&#x8C61;
            --&gt;
            &lt;aop:advisor advice-ref=&quot;myBeforeAdvice&quot; pointcut-ref=&quot;p1&quot;&gt;&lt;/aop:advisor&gt;
        &lt;/aop:config&gt;



    @Test
    public void shouldAnswerWithTrue() {
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext(&quot;spring-config.xml&quot;);
        Calculator cal = applicationContext.getBean(&quot;cal&quot;, Calculator.class);
        Integer add = cal.add(4, 6);
        System.out.println(&quot;add = &quot; + add);

    }
</code></pre><p><strong>&#x901A;&#x77E5;&#x7684;&#x7C7B;&#x578B;</strong></p>
<table>
<thead>
<tr>
<th><strong>&#x901A;&#x77E5;</strong></th>
<th><strong>&#x63CF;&#x8FF0;</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>&#x524D;&#x7F6E;&#x901A;&#x77E5;</strong></td>
<td><strong>&#x5728;&#x4E00;&#x4E2A;&#x65B9;&#x6CD5;&#x6267;&#x884C;&#x524D;,&#x6267;&#x884C;&#x901A;&#x77E5;</strong></td>
</tr>
<tr>
<td><strong>&#x540E;&#x7F6E;&#x901A;&#x77E5;</strong></td>
<td><strong>&#x5728;&#x4E00;&#x4E2A;&#x65B9;&#x6CD5;&#x6267;&#x884C;&#x540E;,&#x6267;&#x884C;&#x901A;&#x77E5;</strong></td>
</tr>
<tr>
<td><strong>&#x8FD4;&#x56DE;&#x540E;&#x901A;&#x77E5;(&#x6700;&#x7EC8;&#x901A;&#x77E5;)</strong></td>
<td><strong>&#x5728;&#x4E00;&#x4E2A;&#x65B9;&#x6CD5;&#x6267;&#x884C;&#x4E4B;&#x540E;,&#x53EA;&#x6709;&#x5728;&#x65B9;&#x6CD5;&#x5B8C;&#x6210;&#x65F6;,&#x624D;&#x80FD;&#x6267;&#x884C;&#x901A;&#x77E5;</strong></td>
</tr>
<tr>
<td><strong>&#x73AF;&#x7ED5;&#x901A;&#x77E5;</strong></td>
<td><strong>&#x5728;&#x4E00;&#x4E2A;&#x65B9;&#x6CD5;&#x8C03;&#x7528; &#x524D;&#x540E;, &#x6267;&#x884C;&#x901A;&#x77E5;</strong></td>
</tr>
<tr>
<td><strong>&#x5F02;&#x5E38;&#x901A;&#x77E5;</strong></td>
<td><strong>&#x5728;&#x4E00;&#x4E2A;&#x65B9;&#x6CD5;&#x6267;&#x884C;&#x4E4B;&#x540E;, &#x53EA;&#x6709;&#x65B9;&#x6CD5;&#x9000;&#x51FA;&#x629B;&#x51FA;&#x5F02;&#x5E38;, &#x624D;&#x80FD;&#x6267;&#x884C;&#x901A;&#x77E5;</strong></td>
</tr>
</tbody>
</table>
<h2 id="2-&#x57FA;&#x4E8E;aspectj-&#x5B9E;&#x73B0;-aop-&#x64CD;&#x4F5C;">2 &#x57FA;&#x4E8E;Aspectj &#x5B9E;&#x73B0; AOP &#x64CD;&#x4F5C;</h2>
<ol>
<li><strong>&#x57FA;&#x4E8E; xml &#x914D;&#x7F6E;&#x6587;&#x4EF6;</strong></li>
<li><strong>&#x57FA;&#x4E8E;&#x6CE8;&#x89E3;&#x7684;&#x5F62;&#x5F0F;&#x5B9E;&#x73B0;</strong></li>
</ol>
<pre><code> xml &#x914D;&#x7F6E;
 &lt;!--  &#x6CE8;&#x89E3;&#x5F00;&#x53D1;:&#x5F00;&#x542F;&#x5305;&#x626B;&#x63CF;   --&gt;
 &lt;context:component-scan base-package=&quot;org.example&quot;&gt;&lt;/context:component-scan&gt;
 &lt;!--  &#x5F00;&#x542F; Aspectj &#x81EA;&#x52A8;&#x4EE3;&#x7406;  &#x9ED8;&#x8BA4;&#x4F7F;&#x7528; jdk&#x7684;&#x65B9;&#x5F0F;,proxy-target-class=&quot;true&quot; &#x4F7F;&#x7528; Cglib   --&gt;
 &lt;aop:aspectj-autoproxy&gt;&lt;/aop:aspectj-autoproxy&gt;


 &#x901A;&#x77E5;&#x7C7B;
 @Component
 @Aspect
 public class LogAdvice {
     @Before(&quot;execution(* *(..))&quot;)
     public void beforeAdvice(){
         System.out.println(&quot;========&#x524D;&#x7F6E;&#x901A;&#x77E5;=======&quot;);
     }

     @AfterReturning(&quot;execution(* *(..))&quot;)
     public void afterReturning(){
         System.out.println(&quot;========&#x540E;&#x7F6E;&#x901A;&#x77E5;=======&quot;);
     }

     @After(&quot;execution(* *(..))&quot;)
     public void after(){
         System.out.println(&quot;========&#x6700;&#x7EC8;&#x901A;&#x77E5;=======&quot;); // &#x65E0;&#x8BBA;&#x7A0B;&#x5E8F;&#x65F6;&#x5019;&#x5F02;&#x5E38;&#x90FD;&#x4F1A;&#x6267;&#x884C;
     }


     @AfterThrowing(&quot;execution(* *(..))&quot;)
     public void afterThrowing(){
         System.out.println(&quot;========&#x5F02;&#x5E38;&#x901A;&#x77E5;=======&quot;); // &#x4E0E;&#x540E;&#x7F6E;&#x901A;&#x77E5; &#x53EA;&#x4F1A;&#x6267;&#x884C;&#x5176;&#x4E2D;&#x4E00;&#x4E2A;
     }


     @Around(&quot;execution(* *(..))&quot;)
     public Object around(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
         System.out.println(&quot;========&#x73AF;&#x7ED5;&#x524D;&#x901A;&#x77E5;=======&quot;);
         Object proceed = proceedingJoinPoint.proceed(); // &#x9700;&#x8981;&#x8FD4;&#x56DE;&#x6539;&#x65B9;&#x6CD5;&#x7684;&#x7ED3;&#x679C;&#x5426;&#x5219;, &#x76EE;&#x6807;&#x5BF9;&#x8C61;&#x6267;&#x884C;&#x7684;&#x65B9;&#x6CD5;&#x65E0;&#x8FD4;&#x56DE;&#x503C;
         System.out.println(&quot;========&#x73AF;&#x7ED5;&#x540E;&#x901A;&#x77E5;=======&quot;);
         return proceed;
     }
 }


 @Test
 public void shouldAnswerWithTrue() {
     ApplicationContext applicationContext = new ClassPathXmlApplicationContext(&quot;spring-config.xml&quot;);
     Calculator cal = applicationContext.getBean(&quot;cal&quot;, Calculator.class);
     System.out.println(&quot;cal = &quot; + cal.getClass());
     Integer add = cal.add(4, 6);
 //        System.out.println(&quot;add = &quot; + add);
     System.out.println();
     System.out.println();
     Integer div = cal.div(2, 0);
 }


 &#x6267;&#x884C;&#x7ED3;&#x679C;
 cal = class org.example.entity.Calculator$$EnhancerBySpringCGLIB$$dc9faed8
 ========&#x73AF;&#x7ED5;&#x524D;&#x901A;&#x77E5;=======
 ========&#x524D;&#x7F6E;&#x901A;&#x77E5;=======
 Calculator &#x6267;&#x884C; add()
 ========&#x540E;&#x7F6E;&#x901A;&#x77E5;=======
 ========&#x6700;&#x7EC8;&#x901A;&#x77E5;=======
 ========&#x73AF;&#x7ED5;&#x540E;&#x901A;&#x77E5;=======


 add = 10
 ========&#x73AF;&#x7ED5;&#x524D;&#x901A;&#x77E5;=======
 ========&#x524D;&#x7F6E;&#x901A;&#x77E5;=======
 Calculator &#x6267;&#x884C; div()
 ========&#x5F02;&#x5E38;&#x901A;&#x77E5;=======
 ========&#x6700;&#x7EC8;&#x901A;&#x77E5;=======

 java.lang.ArithmeticException: / by zero
</code></pre><h1 id="sm-&#x6846;&#x67B6;&#x6574;&#x5408;">SM &#x6846;&#x67B6;&#x6574;&#x5408;</h1>
<p><strong>&#x4F9D;&#x8D56;</strong></p>
<pre><code> &lt;dependencies&gt;
 &lt;!--    mysql&#x9A71;&#x52A8;--&gt;
     &lt;dependency&gt;
       &lt;groupId&gt;mysql&lt;/groupId&gt;
       &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
       &lt;version&gt;5.1.44&lt;/version&gt;
     &lt;/dependency&gt;
     &lt;!--druid--&gt;
     &lt;dependency&gt;
       &lt;groupId&gt;com.alibaba&lt;/groupId&gt;
       &lt;artifactId&gt;druid&lt;/artifactId&gt;
       &lt;version&gt;1.1.10&lt;/version&gt;
     &lt;/dependency&gt;
 &lt;!--mybatis--&gt;
     &lt;dependency&gt;
       &lt;groupId&gt;org.mybatis&lt;/groupId&gt;
       &lt;artifactId&gt;mybatis&lt;/artifactId&gt;
       &lt;version&gt;3.5.7&lt;/version&gt;
     &lt;/dependency&gt;

     &lt;!--IOC &#x4F9D;&#x8D56;&#x6CE8;&#x5165;--&gt;
     &lt;dependency&gt;
       &lt;groupId&gt;org.springframework&lt;/groupId&gt;
       &lt;artifactId&gt;spring-context&lt;/artifactId&gt;
       &lt;version&gt;5.3.9&lt;/version&gt;
     &lt;/dependency&gt;

     &lt;!--mybatis&amp;spring &#x6574;&#x5408;&#x5305;--&gt;

     &lt;dependency&gt;
       &lt;groupId&gt;org.mybatis&lt;/groupId&gt;
       &lt;artifactId&gt;mybatis-spring&lt;/artifactId&gt;
       &lt;version&gt;2.0.5&lt;/version&gt;
     &lt;/dependency&gt;

     &lt;!--aspects &#x5207;&#x9762;--&gt;
     &lt;dependency&gt;
       &lt;groupId&gt;org.springframework&lt;/groupId&gt;
       &lt;artifactId&gt;spring-aspects&lt;/artifactId&gt;
       &lt;version&gt;5.3.9&lt;/version&gt;
     &lt;/dependency&gt;

     &lt;!--jdbc--&gt;
     &lt;dependency&gt;
       &lt;groupId&gt;org.springframework&lt;/groupId&gt;
       &lt;artifactId&gt;spring-jdbc&lt;/artifactId&gt;
       &lt;version&gt;5.3.9&lt;/version&gt;
     &lt;/dependency&gt;

     &lt;!--lombok--&gt;
     &lt;dependency&gt;
       &lt;groupId&gt;org.projectlombok&lt;/groupId&gt;
       &lt;artifactId&gt;lombok&lt;/artifactId&gt;
       &lt;version&gt;1.18.16&lt;/version&gt;
     &lt;/dependency&gt;

     &lt;!-- &#x65E5;&#x5FD7;&#x5DE5;&#x5177;--&gt;
     &lt;dependency&gt;
       &lt;groupId&gt;log4j&lt;/groupId&gt;
       &lt;artifactId&gt;log4j&lt;/artifactId&gt;
       &lt;version&gt;1.2.17&lt;/version&gt;
     &lt;/dependency&gt;
     &lt;!--mybatis&#x5206;&#x9875;&#x63D2;&#x4EF6;--&gt;
     &lt;dependency&gt;
       &lt;groupId&gt;com.github.pagehelper&lt;/groupId&gt;
       &lt;artifactId&gt;pagehelper&lt;/artifactId&gt;
       &lt;version&gt;5.2.1&lt;/version&gt;
     &lt;/dependency&gt;
 &lt;!--&#x6D4B;&#x8BD5;&#x5DE5;&#x5177;--&gt;
     &lt;dependency&gt;
       &lt;groupId&gt;junit&lt;/groupId&gt;
       &lt;artifactId&gt;junit&lt;/artifactId&gt;
       &lt;version&gt;4.11&lt;/version&gt;
       &lt;scope&gt;test&lt;/scope&gt;
     &lt;/dependency&gt;

   &lt;/dependencies&gt;
</code></pre><p><strong>&#x5C06; mybatis &#x548C; spring &#x6574;&#x5408;&#x5C31;&#x662F;&#x5C06; mybatis-config.xml &#x4E2D;&#x7684;&#x914D;&#x7F6E;&#x90FD; &#x5F15;&#x5165;&#x5230; spring-config.xml &#x4E2D;</strong></p>
<p><strong>&#x5305;&#x62EC;: &#x5916;&#x90E8;&#x914D;&#x7F6E;properties&#x6587;&#x4EF6;,&#x522B;&#x540D;, &#x6570;&#x636E;&#x6E90;, &#x4E8B;&#x52A1;, mapper &#x6620;&#x5C04;, &#x548C;&#x5269;&#x4F59;&#x914D;&#x7F6E;</strong></p>
<p><strong>&#x6574;&#x5408;&#x540E;&#x7684; mybatis.xml</strong></p>
<pre><code> &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&gt;
 &lt;!DOCTYPE configuration
         PUBLIC &quot;-//mybatis.org//DTD Config 3.0//EN&quot;
         &quot;http://mybatis.org/dtd/mybatis-3-config.dtd&quot;&gt;
 &lt;configuration&gt;
 &lt;!--    &lt;properties resource=&quot;config/jdbc.properties&quot;&gt;&lt;/properties&gt;--&gt;

     &lt;settings&gt;
         &lt;setting name=&quot;logImpl&quot; value=&quot;STDOUT_LOGGING&quot;/&gt;
         &lt;setting name=&quot;mapUnderscoreToCamelCase&quot; value=&quot;true&quot;/&gt;
         &lt;setting name=&quot;lazyLoadingEnabled&quot; value=&quot;false&quot;/&gt;
     &lt;/settings&gt;

 &lt;!--    &lt;typeAliases&gt;--&gt;
 &lt;!--        &lt;package name=&quot;org.example.spring09.entity&quot;/&gt;--&gt;
 &lt;!--    &lt;/typeAliases&gt;--&gt;

     &lt;plugins&gt;
         &lt;plugin interceptor=&quot;com.github.pagehelper.PageInterceptor&quot;&gt;&lt;/plugin&gt;
     &lt;/plugins&gt;

 &lt;!--    &lt;environments default=&quot;development&quot;&gt;--&gt;
 &lt;!--        &lt;environment id=&quot;development&quot;&gt;--&gt;
 &lt;!--            &lt;transactionManager type=&quot;JDBC&quot;/&gt;--&gt;
 &lt;!--            &lt;dataSource type=&quot;POOLED&quot;&gt;--&gt;
 &lt;!--                &lt;property name=&quot;driver&quot; value=&quot;${jdbc.driver}&quot;/&gt;--&gt;
 &lt;!--                &lt;property name=&quot;url&quot; value=&quot;${jdbc.url}&quot;/&gt;--&gt;
 &lt;!--                &lt;property name=&quot;username&quot; value=&quot;${jdbc.username}&quot;/&gt;--&gt;
 &lt;!--                &lt;property name=&quot;password&quot; value=&quot;${jdbc.password}&quot;/&gt;--&gt;
 &lt;!--            &lt;/dataSource&gt;--&gt;
 &lt;!--        &lt;/environment&gt;--&gt;
 &lt;!--    &lt;/environments&gt;--&gt;

 &lt;!--    &lt;mappers&gt;--&gt;
 &lt;!--        &lt;package name=&quot;org.example.spring09.mapper&quot;/&gt;--&gt;
 &lt;!--    &lt;/mappers&gt;--&gt;
 &lt;/configuration&gt;
</code></pre><p><strong>&#x6574;&#x5408;&#x540E;&#x7684; spring-config.xml</strong></p>
<pre><code> &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
 &lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;
        xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
        xmlns:context=&quot;http://www.springframework.org/schema/context&quot;
        xmlns:aop=&quot;http://www.springframework.org/schema/aop&quot; xmlns:tx=&quot;http://www.springframework.org/schema/tx&quot;
        xsi:schemaLocation=&quot;http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop https://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd&quot;&gt;

     &lt;!--&#x5F15;&#x5165;&#x6570;&#x636E;&#x6E90;&#x53C2;&#x6570;--&gt;
     &lt;context:property-placeholder location=&quot;classpath:config/jdbc.properties&quot;&gt;&lt;/context:property-placeholder&gt;

     &lt;!--&#x5F00;&#x542F;&#x5305;&#x626B;&#x63CF;--&gt;
     &lt;context:component-scan base-package=&quot;org.example.spring09&quot;&gt;&lt;/context:component-scan&gt;
     &lt;!--&#x5F00;&#x542F; aspectj &#x81EA;&#x52A8;&#x6620;&#x5C04;--&gt;
     &lt;aop:aspectj-autoproxy&gt;&lt;/aop:aspectj-autoproxy&gt;

     &lt;!--&#x914D;&#x7F6E;&#x6570;&#x636E;&#x6E90;--&gt;
     &lt;bean id=&quot;druidDataSource&quot; class=&quot;com.alibaba.druid.pool.DruidDataSource&quot; &gt;
         &lt;property name=&quot;driverClassName&quot; value=&quot;${jdbc.driver}&quot;&gt;&lt;/property&gt;
         &lt;property name=&quot;url&quot; value=&quot;${jdbc.url}&quot;&gt;&lt;/property&gt;
         &lt;property name=&quot;username&quot; value=&quot;${jdbc.username}&quot;&gt;&lt;/property&gt;
         &lt;property name=&quot;password&quot; value=&quot;${jdbc.password}&quot;&gt;&lt;/property&gt;
     &lt;/bean&gt;

     &lt;!-- &#x914D;&#x7F6E;sqlSessionFactoryBean --&gt;
     &lt;bean id=&quot;sqlSessionFactoryBean&quot; class=&quot;org.mybatis.spring.SqlSessionFactoryBean&quot;&gt;
         &lt;!--&#x914D;&#x7F6E;&#x6570;&#x636E;&#x6E90;--&gt;
         &lt;property name=&quot;dataSource&quot; ref=&quot;druidDataSource&quot;&gt;&lt;/property&gt;
         &lt;!--&#x914D;&#x7F6E;&#x522B;&#x540D;--&gt;
         &lt;property name=&quot;typeAliasesPackage&quot; value=&quot;org.example.spring09.entity&quot;&gt;&lt;/property&gt;
         &lt;!--&#x914D;&#x7F6E; mapper &#x6620;&#x5C04;&#x6587;&#x4EF6;&#x4F4D;&#x7F6E;--&gt;
         &lt;property name=&quot;mapperLocations&quot; value=&quot;org/example/spring09/mapper/*.xml&quot;&gt;&lt;/property&gt;
         &lt;!--&#x914D;&#x7F6E;&#x5269;&#x4F59; mybatis-config.xml &#x8BBE;&#x7F6E;--&gt;
         &lt;property name=&quot;configLocation&quot; value=&quot;config/mybatis-config.xml&quot;&gt;&lt;/property&gt;
     &lt;/bean&gt;

     &lt;!--&#x914D;&#x7F6E;&#x4E8B;&#x52A1;&#x7BA1;&#x7406;&#x5668;--&gt;
     &lt;bean id=&quot;dataSourceTransactionManager&quot; class=&quot;org.springframework.jdbc.datasource.DataSourceTransactionManager&quot;&gt;
         &lt;property name=&quot;dataSource&quot; ref=&quot;druidDataSource&quot;&gt;&lt;/property&gt;
     &lt;/bean&gt;
     &lt;!--&#x5F00;&#x542F;&#x4E8B;&#x52A1;&#x6CE8;&#x89E3;--&gt;
     &lt;tx:annotation-driven transaction-manager=&quot;dataSourceTransactionManager&quot;&gt;&lt;/tx:annotation-driven&gt;

     &lt;!--&#x626B;&#x63CF;mapper&#x63A5;&#x53E3;--&gt;
     &lt;bean class=&quot;org.mybatis.spring.mapper.MapperScannerConfigurer&quot;&gt;
         &lt;property name=&quot;basePackage&quot; value=&quot;org.example.spring09.mapper&quot;&gt;&lt;/property&gt;
     &lt;/bean&gt;
 &lt;/beans&gt;
</code></pre><blockquote>
<p><strong>&#x914D;&#x7F6E;&#x4E8B;&#x52A1;&#x7BA1;&#x7406;&#x5668;&#x4E4B;&#x540E;&#x8FD8;&#x9700;&#x8981;&#x5F00;&#x542F;&#x4E8B;&#x52A1;&#x6CE8;&#x89E3;&#x626B;&#x63CF;</strong></p>
<p><strong>&#x4F7F;&#x7528;&#x6CE8;&#x89E3;&#x8C03;&#x7528; &#x4E8B;&#x52A1;</strong></p>
</blockquote>
<pre><code>package org.example.spring09.service.impl;

import org.example.spring09.entity.User;
import org.example.spring09.mapper.UserMapper;
import org.example.spring09.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Author Hanmo
 * @Time 2022/12/7
 * @Describe
 */
@Service(&quot;userService&quot;)
//@Transactional
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    /**
     Transactional&#x6CE8;&#x89E3;&#x4E2D;&#x7684;&#x5C5E;&#x6027;
       isolation&#xFF1A;&#x4E8B;&#x52A1;&#x7684;&#x9694;&#x79BB;&#x7EA7;&#x522B;   READ_UNCOMMITTED READ_COMMITTED  REPEATABLE_READ  SERIALIZABLE
       propagation: &#x4E8B;&#x52A1;&#x7684;&#x4F20;&#x64AD;&#x673A;&#x5236;
         Propagation.REQUIRED  &#x9ED8;&#x8BA4;
       rollbackFor&#xFF1A; &#x6307;&#x5B9A;&#x56DE;&#x6EDA;&#x7684;&#x5F02;&#x5E38;
       noRollbackFor: &#x6307;&#x5B9A;&#x4E0D;&#x56DE;&#x6EDA;&#x7684;&#x5F02;&#x5E38;
     */
    @Transactional
    @Override
    public List&lt;User&gt; selectUser() {
        List&lt;User&gt; users = userMapper.selectAll();
        return users;
    }
}
</code></pre><h1 id="&#x4E8B;&#x52A1;&#x4F20;&#x64AD;&#x673A;&#x5236;">&#x4E8B;&#x52A1;&#x4F20;&#x64AD;&#x673A;&#x5236;</h1>
<p><strong>&#x4E8B;&#x52A1;&#x6700;&#x91CD;&#x8981;&#x7684;&#x4E24;&#x4E2A;&#x7279;&#x6027;&#xFF0C;&#x662F;&#x4E8B;&#x52A1;&#x7684;&#x4F20;&#x64AD;&#x7EA7;&#x522B;&#x548C;&#x6570;&#x636E;&#x9694;&#x79BB;&#x7EA7;&#x522B;&#x3002;&#x4F20;&#x64AD;&#x7EA7;&#x522B;&#x5B9A;&#x4E49;&#x7684;&#x662F;&#x4E8B;&#x52A1;&#x7684;&#x63A7;&#x5236;&#x8303;&#x56F4;&#xFF0C;&#x4E8B;&#x52A1;&#x9694;&#x79BB;&#x7EA7;&#x522B;&#x5B9A;&#x4E49;&#x7684;&#x662F;&#x4E8B;&#x52A1;&#x5728;&#x6570;&#x636E;&#x5E93;&#x8BFB;&#x5199;&#x65B9;&#x9762;&#x7684;&#x63A7;&#x5236;&#x8303;&#x56F4;&#x3002;</strong></p>
<p><strong>&#x4EE5;&#x4E0B;&#x662F;&#x4E8B;&#x52A1;&#x7684;7&#x79CD;&#x4F20;&#x64AD;&#x7EA7;&#x522B;&#xFF1A;</strong></p>
<p><strong>1&#xFF09; <strong>**</strong></strong>PROPAGATION_REQUIRED<strong>**</strong> &#xFF0C;&#x9ED8;&#x8BA4;&#x7684;spring&#x4E8B;&#x52A1;&#x4F20;&#x64AD;&#x7EA7;&#x522B;&#xFF0C;&#x4F7F;&#x7528;&#x8BE5;&#x7EA7;&#x522B;&#x7684;&#x7279;&#x70B9;&#x662F;&#xFF0C;&#x5982;&#x679C;&#x4E0A;&#x4E0B;&#x6587;&#x4E2D;&#x5DF2;&#x7ECF;&#x5B58;&#x5728;&#x4E8B;&#x52A1;&#xFF0C;&#x90A3;&#x4E48;&#x5C31;&#x52A0;&#x5165;&#x5230;&#x4E8B;&#x52A1;&#x4E2D;&#x6267;&#x884C;&#xFF0C;&#x5982;&#x679C;&#x5F53;&#x524D;&#x4E0A;&#x4E0B;&#x6587;&#x4E2D;&#x4E0D;&#x5B58;&#x5728;&#x4E8B;&#x52A1;&#xFF0C;&#x5219;&#x65B0;&#x5EFA;&#x4E8B;&#x52A1;&#x6267;&#x884C;&#x3002;&#x6240;&#x4EE5;&#x8FD9;&#x4E2A;&#x7EA7;&#x522B;&#x901A;&#x5E38;&#x80FD;&#x6EE1;&#x8DB3;&#x5904;&#x7406;&#x5927;&#x591A;&#x6570;&#x7684;&#x4E1A;&#x52A1;&#x573A;&#x666F;&#x3002;</p>
<p><strong>2&#xFF09;<strong>**</strong></strong>PROPAGATION_SUPPORTS<strong>**</strong> &#xFF0C;&#x4ECE;&#x5B57;&#x9762;&#x610F;&#x601D;&#x5C31;&#x77E5;&#x9053;&#xFF0C;supports&#xFF0C;&#x652F;&#x6301;&#xFF0C;&#x8BE5;&#x4F20;&#x64AD;&#x7EA7;&#x522B;&#x7684;&#x7279;&#x70B9;&#x662F;&#xFF0C;&#x5982;&#x679C;&#x4E0A;&#x4E0B;&#x6587;&#x5B58;&#x5728;&#x4E8B;&#x52A1;&#xFF0C;&#x5219;&#x652F;&#x6301;&#x4E8B;&#x52A1;&#x52A0;&#x5165;&#x4E8B;&#x52A1;&#xFF0C;&#x5982;&#x679C;&#x6CA1;&#x6709;&#x4E8B;&#x52A1;&#xFF0C;&#x5219;&#x4F7F;&#x7528;&#x975E;&#x4E8B;&#x52A1;&#x7684;&#x65B9;&#x5F0F;&#x6267;&#x884C;&#x3002;&#x6240;&#x4EE5;&#x8BF4;&#xFF0C;&#x5E76;&#x975E;&#x6240;&#x6709;&#x7684;&#x5305;&#x5728;transactionTemplate.execute&#x4E2D;&#x7684;&#x4EE3;&#x7801;&#x90FD;&#x4F1A;&#x6709;&#x4E8B;&#x52A1;&#x652F;&#x6301;&#x3002;&#x8FD9;&#x4E2A;&#x901A;&#x5E38;&#x662F;&#x7528;&#x6765;&#x5904;&#x7406;&#x90A3;&#x4E9B;&#x5E76;&#x975E;&#x539F;&#x5B50;&#x6027;&#x7684;&#x975E;&#x6838;&#x5FC3;&#x4E1A;&#x52A1;&#x903B;&#x8F91;&#x64CD;&#x4F5C;&#x3002;&#x5E94;&#x7528;&#x573A;&#x666F;&#x8F83;&#x5C11;&#x3002;</p>
<p><strong>3&#xFF09;<strong>**</strong></strong>PROPAGATION_MANDATORY<strong>**</strong> &#xFF0C; &#x8BE5;&#x7EA7;&#x522B;&#x7684;&#x4E8B;&#x52A1;&#x8981;&#x6C42;&#x4E0A;&#x4E0B;&#x6587;&#x4E2D;&#x5FC5;&#x987B;&#x8981;&#x5B58;&#x5728;&#x4E8B;&#x52A1;&#xFF0C;&#x5426;&#x5219;&#x5C31;&#x4F1A;&#x629B;&#x51FA;&#x5F02;&#x5E38;&#xFF01;&#x914D;&#x7F6E;&#x8BE5;&#x65B9;&#x5F0F;&#x7684;&#x4F20;&#x64AD;&#x7EA7;&#x522B;&#x662F;&#x6709;&#x6548;&#x7684;&#x63A7;&#x5236;&#x4E0A;&#x4E0B;&#x6587;&#x8C03;&#x7528;&#x4EE3;&#x7801;&#x9057;&#x6F0F;&#x6DFB;&#x52A0;&#x4E8B;&#x52A1;&#x63A7;&#x5236;&#x7684;&#x4FDD;&#x8BC1;&#x624B;&#x6BB5;&#x3002;&#x6BD4;&#x5982;&#x4E00;&#x6BB5;&#x4EE3;&#x7801;&#x4E0D;&#x80FD;&#x5355;&#x72EC;&#x88AB;&#x8C03;&#x7528;&#x6267;&#x884C;&#xFF0C;&#x4F46;&#x662F;&#x4E00;&#x65E6;&#x88AB;&#x8C03;&#x7528;&#xFF0C;&#x5C31;&#x5FC5;&#x987B;&#x6709;&#x4E8B;&#x52A1;&#x5305;&#x542B;&#x7684;&#x60C5;&#x51B5;&#xFF0C;&#x5C31;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x8FD9;&#x4E2A;&#x4F20;&#x64AD;&#x7EA7;&#x522B;&#x3002;</p>
<p><strong>4&#xFF09;<strong>**</strong></strong>PROPAGATION_REQUIRES_NEW<strong>**</strong> &#xFF0C;&#x4ECE;&#x5B57;&#x9762;&#x5373;&#x53EF;&#x77E5;&#x9053;&#xFF0C;new&#xFF0C;&#x6BCF;&#x6B21;&#x90FD;&#x8981;&#x4E00;&#x4E2A;&#x65B0;&#x4E8B;&#x52A1;&#xFF0C;&#x8BE5;&#x4F20;&#x64AD;&#x7EA7;&#x522B;&#x7684;&#x7279;&#x70B9;&#x662F;&#xFF0C;&#x6BCF;&#x6B21;&#x90FD;&#x4F1A;&#x65B0;&#x5EFA;&#x4E00;&#x4E2A;&#x4E8B;&#x52A1;&#xFF0C;&#x5E76;&#x4E14;&#x540C;&#x65F6;&#x5C06;&#x4E0A;&#x4E0B;&#x6587;&#x4E2D;&#x7684;&#x4E8B;&#x52A1;&#x6302;&#x8D77;&#xFF0C;&#x6267;&#x884C;&#x5F53;&#x524D;&#x65B0;&#x5EFA;&#x4E8B;&#x52A1;&#x5B8C;&#x6210;&#x4EE5;&#x540E;&#xFF0C;&#x4E0A;&#x4E0B;&#x6587;&#x4E8B;&#x52A1;&#x6062;&#x590D;&#x518D;&#x6267;&#x884C;&#x3002;</p>
<p><strong>&#x8FD9;&#x662F;&#x4E00;&#x4E2A;&#x5F88;&#x6709;&#x7528;&#x7684;&#x4F20;&#x64AD;&#x7EA7;&#x522B;&#xFF0C;&#x4E3E;&#x4E00;&#x4E2A;&#x5E94;&#x7528;&#x573A;&#x666F;&#xFF1A;&#x73B0;&#x5728;&#x6709;&#x4E00;&#x4E2A;&#x53D1;&#x9001;100&#x4E2A;&#x7EA2;&#x5305;&#x7684;&#x64CD;&#x4F5C;&#xFF0C;&#x5728;&#x53D1;&#x9001;&#x4E4B;&#x524D;&#xFF0C;&#x8981;&#x505A;&#x4E00;&#x4E9B;&#x7CFB;&#x7EDF;&#x7684;&#x521D;&#x59CB;&#x5316;&#x3001;&#x9A8C;&#x8BC1;&#x3001;&#x6570;&#x636E;&#x8BB0;&#x5F55;&#x64CD;&#x4F5C;&#xFF0C;&#x7136;&#x540E;&#x53D1;&#x9001;100&#x5C01;&#x7EA2;&#x5305;&#xFF0C;&#x7136;&#x540E;&#x518D;&#x8BB0;&#x5F55;&#x53D1;&#x9001;&#x65E5;&#x5FD7;&#xFF0C;&#x53D1;&#x9001;&#x65E5;&#x5FD7;&#x8981;&#x6C42;100%&#x7684;&#x51C6;&#x786E;&#xFF0C;&#x5982;&#x679C;&#x65E5;&#x5FD7;&#x4E0D;&#x51C6;&#x786E;&#xFF0C;&#x90A3;&#x4E48;&#x6574;&#x4E2A;&#x7236;&#x4E8B;&#x52A1;&#x903B;&#x8F91;&#x9700;&#x8981;&#x56DE;&#x6EDA;&#x3002;</strong>
<strong>&#x600E;&#x4E48;&#x5904;&#x7406;&#x6574;&#x4E2A;&#x4E1A;&#x52A1;&#x9700;&#x6C42;&#x5462;&#xFF1F;&#x5C31;&#x662F;&#x901A;&#x8FC7;&#x8FD9;&#x4E2A;PROPAGATION_REQUIRES_NEW &#x7EA7;&#x522B;&#x7684;&#x4E8B;&#x52A1;&#x4F20;&#x64AD;&#x63A7;&#x5236;&#x5C31;&#x53EF;&#x4EE5;&#x5B8C;&#x6210;&#x3002;&#x53D1;&#x9001;&#x7EA2;&#x5305;&#x7684;&#x5B50;&#x4E8B;&#x52A1;&#x4E0D;&#x4F1A;&#x76F4;&#x63A5;&#x5F71;&#x54CD;&#x5230;&#x7236;&#x4E8B;&#x52A1;&#x7684;&#x63D0;&#x4EA4;&#x548C;&#x56DE;&#x6EDA;&#x3002;</strong></p>
<p><strong>5&#xFF09;<strong>**</strong></strong>PROPAGATION_NOT_SUPPORTED<strong>**</strong> &#xFF0C;&#x8FD9;&#x4E2A;&#x4E5F;&#x53EF;&#x4EE5;&#x4ECE;&#x5B57;&#x9762;&#x5F97;&#x77E5;&#xFF0C;not supported &#xFF0C;&#x4E0D;&#x652F;&#x6301;&#xFF0C;&#x5F53;&#x524D;&#x7EA7;&#x522B;&#x7684;&#x7279;&#x70B9;&#x5C31;&#x662F;&#x4E0A;&#x4E0B;&#x6587;&#x4E2D;&#x5B58;&#x5728;&#x4E8B;&#x52A1;&#xFF0C;&#x5219;&#x6302;&#x8D77;&#x4E8B;&#x52A1;&#xFF0C;&#x6267;&#x884C;&#x5F53;&#x524D;&#x903B;&#x8F91;&#xFF0C;&#x7ED3;&#x675F;&#x540E;&#x6062;&#x590D;&#x4E0A;&#x4E0B;&#x6587;&#x7684;&#x4E8B;&#x52A1;&#x3002;</p>
<p><strong>&#x8FD9;&#x4E2A;&#x7EA7;&#x522B;&#x6709;&#x4EC0;&#x4E48;&#x597D;&#x5904;&#xFF1F;&#x53EF;&#x4EE5;&#x5E2E;&#x52A9;&#x4F60;&#x5C06;&#x4E8B;&#x52A1;&#x6781;&#x53EF;&#x80FD;&#x7684;&#x7F29;&#x5C0F;&#x3002;&#x6211;&#x4EEC;&#x77E5;&#x9053;&#x4E00;&#x4E2A;&#x4E8B;&#x52A1;&#x8D8A;&#x5927;&#xFF0C;&#x5B83;&#x5B58;&#x5728;&#x7684;&#x98CE;&#x9669;&#x4E5F;&#x5C31;&#x8D8A;&#x591A;&#x3002;&#x6240;&#x4EE5;&#x5728;&#x5904;&#x7406;&#x4E8B;&#x52A1;&#x7684;&#x8FC7;&#x7A0B;&#x4E2D;&#xFF0C;&#x8981;&#x4FDD;&#x8BC1;&#x5C3D;&#x53EF;&#x80FD;&#x7684;&#x7F29;&#x5C0F;&#x8303;&#x56F4;&#x3002;&#x6BD4;&#x5982;&#x4E00;&#x6BB5;&#x4EE3;&#x7801;&#xFF0C;&#x662F;&#x6BCF;&#x6B21;&#x903B;&#x8F91;&#x64CD;&#x4F5C;&#x90FD;&#x5FC5;&#x987B;&#x8C03;&#x7528;&#x7684;&#xFF0C;&#x6BD4;&#x5982;&#x5FAA;&#x73AF;1000&#x6B21;&#x7684;&#x67D0;&#x4E2A;&#x975E;&#x6838;&#x5FC3;&#x4E1A;&#x52A1;&#x903B;&#x8F91;&#x64CD;&#x4F5C;&#x3002;&#x8FD9;&#x6837;&#x7684;&#x4EE3;&#x7801;&#x5982;&#x679C;&#x5305;&#x5728;&#x4E8B;&#x52A1;&#x4E2D;&#xFF0C;&#x52BF;&#x5FC5;&#x9020;&#x6210;&#x4E8B;&#x52A1;&#x592A;&#x5927;&#xFF0C;&#x5BFC;&#x81F4;&#x51FA;&#x73B0;&#x4E00;&#x4E9B;&#x96BE;&#x4EE5;&#x8003;&#x8651;&#x5468;&#x5168;&#x7684;&#x5F02;&#x5E38;&#x60C5;&#x51B5;&#x3002;&#x6240;&#x4EE5;&#x8FD9;&#x4E2A;&#x4E8B;&#x52A1;&#x8FD9;&#x4E2A;&#x7EA7;&#x522B;&#x7684;&#x4F20;&#x64AD;&#x7EA7;&#x522B;&#x5C31;&#x6D3E;&#x4E0A;&#x7528;&#x573A;&#x4E86;&#x3002;&#x7528;&#x5F53;&#x524D;&#x7EA7;&#x522B;&#x7684;&#x4E8B;&#x52A1;&#x6A21;&#x677F;&#x62B1;&#x8D77;&#x6765;&#x5C31;&#x53EF;&#x4EE5;&#x4E86;&#x3002;</strong></p>
<p><strong>6&#xFF09;<strong>**</strong></strong>PROPAGATION_NEVER<strong>**</strong> &#xFF0C;&#x8BE5;&#x4E8B;&#x52A1;&#x66F4;&#x4E25;&#x683C;&#xFF0C;&#x4E0A;&#x9762;&#x4E00;&#x4E2A;&#x4E8B;&#x52A1;&#x4F20;&#x64AD;&#x7EA7;&#x522B;&#x53EA;&#x662F;&#x4E0D;&#x652F;&#x6301;&#x800C;&#x5DF2;&#xFF0C;&#x6709;&#x4E8B;&#x52A1;&#x5C31;&#x6302;&#x8D77;&#xFF0C;&#x800C;PROPAGATION_NEVER&#x4F20;&#x64AD;&#x7EA7;&#x522B;&#x8981;&#x6C42;&#x4E0A;&#x4E0B;&#x6587;&#x4E2D;&#x4E0D;&#x80FD;&#x5B58;&#x5728;&#x4E8B;&#x52A1;&#xFF0C;&#x4E00;&#x65E6;&#x6709;&#x4E8B;&#x52A1;&#xFF0C;&#x5C31;&#x629B;&#x51FA;runtime&#x5F02;&#x5E38;&#xFF0C;&#x5F3A;&#x5236;&#x505C;&#x6B62;&#x6267;&#x884C;&#xFF01;&#x8FD9;&#x4E2A;&#x7EA7;&#x522B;&#x4E0A;&#x8F88;&#x5B50;&#x8DDF;&#x4E8B;&#x52A1;&#x6709;&#x4EC7;&#x3002;</p>
<p><strong>7&#xFF09;<strong>**</strong></strong>PROPAGATION_NESTED<strong>**</strong> &#xFF0C;&#x5B57;&#x9762;&#x4E5F;&#x53EF;&#x77E5;&#x9053;&#xFF0C;nested&#xFF0C;&#x5D4C;&#x5957;&#x7EA7;&#x522B;&#x4E8B;&#x52A1;&#x3002;&#x8BE5;&#x4F20;&#x64AD;&#x7EA7;&#x522B;&#x7279;&#x5F81;&#x662F;&#xFF0C;&#x5982;&#x679C;&#x4E0A;&#x4E0B;&#x6587;&#x4E2D;&#x5B58;&#x5728;&#x4E8B;&#x52A1;&#xFF0C;&#x5219;&#x5D4C;&#x5957;&#x4E8B;&#x52A1;&#x6267;&#x884C;&#xFF0C;&#x5982;&#x679C;&#x4E0D;&#x5B58;&#x5728;&#x4E8B;&#x52A1;&#xFF0C;&#x5219;&#x65B0;&#x5EFA;&#x4E8B;&#x52A1;&#x3002;</p>
<pre><code>@Transactional(propagation=Propagation.REQUIRED,rollbackFor=Exception.class)
</code></pre>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"书名","level":"1.1","depth":1,"next":{"title":"Java","level":"2.1","depth":1,"ref":"","articles":[{"title":"001环境变量","level":"2.1.1","depth":2,"path":"books/java/001环境变量.md","ref":"books/java/001环境变量.md","articles":[]},{"title":"002Java初体验","level":"2.1.2","depth":2,"path":"books/java/002Java初体验.md","ref":"books/java/002Java初体验.md","articles":[]},{"title":"003变量命名及数据类型","level":"2.1.3","depth":2,"path":"books/java/003变量命名及数据类型.md","ref":"books/java/003变量命名及数据类型.md","articles":[]},{"title":"004运算符","level":"2.1.4","depth":2,"path":"books/java/004运算符.md","ref":"books/java/004运算符.md","articles":[]},{"title":"005选择结构","level":"2.1.5","depth":2,"path":"books/java/005选择结构.md","ref":"books/java/005选择结构.md","articles":[]},{"title":"006循环结构","level":"2.1.6","depth":2,"path":"books/java/006循环结构.md","ref":"books/java/006循环结构.md","articles":[]},{"title":"007数组","level":"2.1.7","depth":2,"path":"books/java/007数组.md","ref":"books/java/007数组.md","articles":[]},{"title":"008类和对象方法","level":"2.1.8","depth":2,"path":"books/java/008类和对象方法.md","ref":"books/java/008类和对象方法.md","articles":[]},{"title":"009构造方法","level":"2.1.9","depth":2,"path":"books/java/009构造方法.md","ref":"books/java/009构造方法.md","articles":[]},{"title":"010封装与关键字Static","level":"2.1.10","depth":2,"path":"books/java/010封装与关键字static.md","ref":"books/java/010封装与关键字static.md","articles":[]},{"title":"011 继承","level":"2.1.11","depth":2,"path":"books/java/011 继承.md","ref":"books/java/011 继承.md","articles":[]},{"title":"012方法重写","level":"2.1.12","depth":2,"path":"books/java/012方法重写.md","ref":"books/java/012方法重写.md","articles":[]},{"title":"013多态","level":"2.1.13","depth":2,"path":"books/java/013多态.md","ref":"books/java/013多态.md","articles":[]},{"title":"014抽象类抽象方法","level":"2.1.14","depth":2,"path":"books/java/014抽象类抽象方法.md","ref":"books/java/014抽象类抽象方法.md","articles":[]},{"title":"015接口","level":"2.1.15","depth":2,"path":"books/java/015接口.md","ref":"books/java/015接口.md","articles":[]},{"title":"016异常","level":"2.1.16","depth":2,"path":"books/java/016异常.md","ref":"books/java/016异常.md","articles":[]},{"title":"017集合","level":"2.1.17","depth":2,"path":"books/java/017集合.md","ref":"books/java/017集合.md","articles":[]},{"title":"017集合2","level":"2.1.18","depth":2,"path":"books/java/017集合2.md","ref":"books/java/017集合2.md","articles":[]},{"title":"018泛型","level":"2.1.19","depth":2,"path":"books/java/018泛型.md","ref":"books/java/018泛型.md","articles":[]},{"title":"019Collections算法类","level":"2.1.20","depth":2,"path":"books/java/019Collections算法类.md","ref":"books/java/019Collections算法类.md","articles":[]},{"title":"020枚举","level":"2.1.21","depth":2,"path":"books/java/020枚举.md","ref":"books/java/020枚举.md","articles":[]},{"title":"021包装类","level":"2.1.22","depth":2,"path":"books/java/021包装类.md","ref":"books/java/021包装类.md","articles":[]},{"title":"022常用类","level":"2.1.23","depth":2,"path":"books/java/022常用类.md","ref":"books/java/022常用类.md","articles":[]},{"title":"023File类","level":"2.1.24","depth":2,"path":"books/java/023File类.md","ref":"books/java/023File类.md","articles":[]},{"title":"024IO流","level":"2.1.25","depth":2,"path":"books/java/024IO流.md","ref":"books/java/024IO流.md","articles":[]},{"title":"025多线程","level":"2.1.26","depth":2,"path":"books/java/025多线程.md","ref":"books/java/025多线程.md","articles":[]},{"title":"025多线程线程池","level":"2.1.27","depth":2,"path":"books/java/025多线程线程池.md","ref":"books/java/025多线程线程池.md","articles":[]},{"title":"026网络编程Socket","level":"2.1.28","depth":2,"path":"books/java/026网络编程Socket.md","ref":"books/java/026网络编程Socket.md","articles":[]},{"title":"027XML解析","level":"2.1.29","depth":2,"path":"books/java/027XML解析.md","ref":"books/java/027XML解析.md","articles":[]},{"title":"028 注解","level":"2.1.30","depth":2,"path":"books/java/028 注解.md","ref":"books/java/028 注解.md","articles":[]},{"title":"029 Lambda表达式","level":"2.1.31","depth":2,"path":"books/java/029 Lambda表达式.md","ref":"books/java/029 Lambda表达式.md","articles":[]},{"title":"029 反射","level":"2.1.32","depth":2,"path":"books/java/029 反射.md","ref":"books/java/029 反射.md","articles":[]}]},"dir":"ltr"},"config":{"plugins":["search-pro","code","back-to-top-button","theme-comscore","intopic-toc","flexible-alerts","expandable-chapters"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"intopic-toc":{"selector":".markdown-section h1, .markdown-section h2, .markdown-section h3, .markdown-section h4, .markdown-section h5, .markdown-section h6","mode":"nested","maxDepth":6,"isCollapsed":true,"isScrollspyActive":true,"visible":true,"label":"In this article"},"search-pro":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"code":{"copyButtons":true},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"theme-comscore":{},"back-to-top-button":{},"flexible-alerts":{"style":"callout","note":{"label":"Note","icon":"fa fa-info-circle","className":"info"},"tip":{"label":"Tip","icon":"fa fa-lightbulb-o","className":"tip"},"warning":{"label":"Warning","icon":"fa fa-exclamation-triangle","className":"warning"},"danger":{"label":"Attention","icon":"fa fa-ban","className":"danger"}},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"expandable-chapters":{}},"theme":"default","author":"作者","lang":"zh-cn","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"isbn":"图书编号","variables":{},"title":"书名","gitbook":"*","description":"描述"},"file":{"path":"README.md","mtime":"2022-12-09T03:01:39.285Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2023-03-01T12:24:55.135Z"},"basePath":".","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="gitbook/gitbook.js"></script>
    <script src="gitbook/theme.js"></script>
    
        
        <script src="gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-code/plugin.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-back-to-top-button/plugin.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-intopic-toc/anchor.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-intopic-toc/gumshoe.polyfills.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-intopic-toc/plugin.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-flexible-alerts/plugin.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

